package tech.yangzhijie.basic.gui;

import javax.swing.*;
import java.awt.*;
import java.util.concurrent.TimeUnit;

/**
 * @Author: 探险家劫
 * @Date: 2021/11/24 13:21
 */
public class SubmitSwingProgram extends JFrame {

    private JLabel jLabel;

    public SubmitSwingProgram() throws HeadlessException {
        super("Hello World");
        jLabel = new JLabel("A label");
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setSize(300,100);
        add(jLabel);

    }

    static SubmitSwingProgram ssp;

    public static void main(String[] args) throws InterruptedException {
        SwingUtilities.invokeLater(()->{
            ssp = new SubmitSwingProgram();
        });
        TimeUnit.SECONDS.sleep(1);
        SwingUtilities.invokeLater(()->{
            ssp.getjLabel().setText("第三个label");
        });
    }

    public JLabel getjLabel() {
        return jLabel;
    }
}
